package controller;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.catalina.websocket.StreamInbound;
import org.apache.catalina.websocket.WebSocketServlet;
import org.jivesoftware.smack.XMPPConnection;

import utils.WSMessages;


@WebServlet("/ws")
public class WebSocketProvider extends WebSocketServlet{
	
	@Override
	protected StreamInbound createWebSocketInbound(String arg0,
			HttpServletRequest request){
		
		HttpSession sessao = request.getSession();
		System.out.println("a conexao eh: " + sessao.getAttribute("conexaoXmpp"));		
		
		WSMessages messages = new WSMessages();
		messages.setUsuarioLogado("campeao");
		messages.setConexaoXmpp((XMPPConnection)sessao.getAttribute("conexaoXmpp"));
		
		return messages;
	}

	
}
